#!/usr/bin/python2.7
#coding=utf8
from ana_excel.config.register_config import register
from ana_excel.common.getexcelvalue import getvalue
from ana_excel.common.database import init_db
from ana_excel.common.database import DataBase
from ana_excel.common.merge_data2table import merge_into_table
from ana_excel.common.merge_data2table import merge_list_into_table

def main():
    database = DataBase()
    session = database.dbsession()
    rm = register()
    for index in rm.keys():
        print(index)
        cell_value = getvalue(index, rm[index])
        if isinstance(cell_value, float):
            merge_into_table(index, rm[index], cell_value, session)
        elif isinstance(cell_value, list):
            merge_list_into_table(index, rm[index], cell_value, session)
        else:
            pass

def database_init():
    init_db()


if __name__ == "__main__":
    init_db()